#!/usr/bin/env python
"""Remote Python Command Engine (RyCE) main application entry point.
"""
__author__ = 'Don B. Stringham'
__version__ = '0.01'
__date__ = '10-27-2006 12:41 PM'
#-IMPORTS----------------------------------------------------------------------
import sys
#import env
import cmdeng #-Heart of the application
import cmdline #-Command-line parameters module
import logging
import plogging #-Logging functions specific to RyCE
#-CONSTANTS--------------------------------------------------------------------
OP_LISTALL = 'listall'
#-FUNCTIONS--------------------------------------------------------------------
def main(argv=sys.argv):
    """Main function for RyCE.
    """
    plogging.setup(cmdline.options.verbose)
    log = logging.getLogger('ryce')
    if cmdline.options.verbose:
        log.info(cmdline.getOptionsString())
    if cmdline.options.version:
        log.info('RyCE version: %s' % __version__)
    elif cmdline.options.cluster == '' and cmdline.options.ip == '' and cmdline.options.op == OP_LISTALL:
        log.error('Must specify either a -c/--cluster or -i/--ip parameter(s), exiting.')
        return -1
    ce = cmdeng.CmdEngine()
    ce.execute()
    return 0

if __name__ == '__main__':
    cmdline.setup(sys.argv)
    sys.exit(main())
